package com.tencent.wxcloudrun.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tencent.wxcloudrun.dao.BandInfoMapper;
import com.tencent.wxcloudrun.model.BandInfo;
import com.tencent.wxcloudrun.service.BandInfoService;

@Service
public class BandInfoServiceImpl implements BandInfoService {

  final BandInfoMapper bandInfoMapper;

  public BandInfoServiceImpl(@Autowired BandInfoMapper bandInfoMapper) {
    this.bandInfoMapper = bandInfoMapper;
  }

  @Override
  public BandInfo getOne(Integer id) {
    return bandInfoMapper.getBandInfo(id);
  }

  @Override
  public List<BandInfo> getList() {
    return bandInfoMapper.getList();
  }

  @Override
  public BandInfo vote(Integer id, Integer vote) {
    BandInfo bandInfo = bandInfoMapper.getBandInfo(id);
    bandInfo.setVote(vote);
    bandInfoMapper.upsertBandInfo(bandInfo);
    return bandInfoMapper.getBandInfo(id);
  }

}
